package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test3_entity;
import edu.xidian.sselab.cloudcourse.repository.test3_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class test3_controller {

    @Autowired
    private test3_Repository test3_repository;

    @RequestMapping("/test3")
    public String test3_try(Model model){
        model.addAttribute("title", "汽车品牌销量TOP10");
        return "test3";
    }

    @RequestMapping("/test19")
    public @ResponseBody
    List test3_try2() throws IOException {

        List<test3_entity> recordList = test3_repository.find();

        System.out.println("以下是销售量前十的品牌TOP10，按照销售量的倒序排序：");
        for(test3_entity t:recordList){
            System.out.println(t);
        }
        return recordList;
    }
}
